<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>系统管理</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
    <link href="../plugin/jquery-zoomify/zoomify.min.css" rel="stylesheet"/>

    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/fileinput.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/file_input/local_zh.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/plugin/datatimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/jquery-zoomify/zoomify.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/soul/utils3.js"></script>
    <script src='../base/base.js'></script>
</head>
<body>

<script>
    $(function () {
        var resp = AjaxUtil.isLogin();
        if (!resp) return;

        var module = 'system_config';


        // 工具条配置
        var toolbar = {
            default: [false, false, false, false],// back;add;edit;remove
            dialog: [50, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '开启/关闭全部用户投资BHPC',
                glyphicon: 'list',
                onclick: 'showEthereumWalletDetail',
            }, {
                name: '审核',
                glyphicon: 'list',
                onclick: 'auditWhiteList',
            }]
        };
        var bootstrapTable = {
            columns: [{
                radio: true
            }, {
                field: 'key',
                title: '配置key',
                align: 'center',
            }, {
                field: 'name',
                title: '名称',
                align: 'center',
            }, {
                field: 'value',
                title: '值',
                align: 'center',
            }, {
                field: 'key',
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    if (value == 'isAllIco') {
                        return '<button class="btn btn-danger" onclick="userManager.reserveIsAllIco();">开启/关闭全部用户投资BHPC</button>'
                    } else if (value == 'bhpcToDollar') {
                        return '<button class="btn btn-danger" onclick="userManager.set_bhpc_to_dollar();">设置算力币汇率</button>'
                    } else if (value == 'icoProcess') {
                        return '<button class="btn btn-danger" onclick="userManager.set_ico_process();">设置ICO进度</button>'
                    }else if (value == 'transferContant') {
                        return '<button class="btn btn-danger" onclick="userManager.set_account_number();">设置转账联系人</button>'
                    }else if (value == 'transferWechat') {
                        return '<button class="btn btn-danger" onclick="userManager.set_account_address();">设置转账微信号</button>'
                    }
                }
            }],

        }

        userManager = SingleTablePageCreateUtil.createInstance(module, null, null, null, bootstrapTable);

        userManager.reserveIsAllIco = function () {
            SwalUtil.confirm(function () {
                var resp = AjaxUtil.postJson('system_config/reserve_ico', {
                    key: 'isAllIco'
                });
                if (!resp) return;
                $('#system_config_table').bootstrapTable('refresh');
            });
        };
        // userManager.setBitcoinToDollar = function () {
        //     swal({
        //         title: '请输入比特币到美元的汇率',
        //         input: 'text',
        //         showCancelButton: true,
        //     }).then(function(inputValue) {
        //         if (inputValue === false)
        //             return false;
        //         if (inputValue === "") {
        //             return false
        //         }
        //         var resp = AjaxUtil.postJson('system_config/setBitcoinToDollar',{
        //             bitcoinToDollar : inputValue
        //         });
        //
        //         if (!resp) return;
        //         $('#system_config_table').bootstrapTable('refresh');
        //     })
        // };
        // userManager.setEthereumToDollar = function () {
        //     swal({
        //         title: '请输入以太币到美元的汇率',
        //         input: 'text',
        //         showCancelButton: true,
        //     }).then(function(inputValue) {
        //         if (inputValue === false)
        //             return false;
        //         if (inputValue === "") {
        //             return false
        //         }
        //         var resp = AjaxUtil.postJson('system_config/setEthereumToDollar',{
        //             ethereumToDollar : inputValue
        //         });
        //
        //         if (!resp) return;
        //         $('#system_config_table').bootstrapTable('refresh');
        //     })
        // };
        userManager.set_bhpc_to_dollar = function () {
            swal({
                title: '请输入算力币到美元的汇率',
                input: 'text',
                showCancelButton: true,
            }).then(function (inputValue) {
                if (inputValue === false)
                    return false;
                if (inputValue === "") {
                    return false
                }
                var resp = AjaxUtil.postJson('system_config/set_bhpc_to_dollar', {
                    bhpcToDollar: inputValue
                });

                if (!resp) return;
                $('#system_config_table').bootstrapTable('refresh');
            })
        };
        userManager.set_ico_process = function () {
            swal({
                title: '请输入ICO进度（585,293-1,064,169.091.25-569）',
                input: 'text',
                showCancelButton: true,
            }).then(function (inputValue) {
                if (inputValue === false)
                    return false;
                if (inputValue === "") {
                    return false
                }
                var resp = AjaxUtil.postJson('system_config/set_ico_process', {
                    process: inputValue
                });

                if (!resp) return;
                $('#system_config_table').bootstrapTable('refresh');
            })
        };

        userManager.set_account_number = function () {
            swal({
                title: '请输转账联系人',
                input: 'text',
                showCancelButton: true,
            }).then(function (inputValue) {
                if (inputValue === false)
                    return false;
                if (inputValue === "") {
                    return false
                }
                var resp = AjaxUtil.postJson('system_config/set_account_number', {
                    accountNumber: inputValue
                });

                if (!resp) return;
                $('#system_config_table').bootstrapTable('refresh');
            })
        };

        userManager.set_account_address = function () {
            swal({
                title: '请输入转账微信号',
                input: 'text',
                showCancelButton: true,
            }).then(function (inputValue) {
                if (inputValue === false)
                    return false;
                if (inputValue === "") {
                    return false
                }
                var resp = AjaxUtil.postJson('system_config/set_account_address', {
                    accountAddress: inputValue
                });

                if (!resp) return;
                $('#system_config_table').bootstrapTable('refresh');
            })
        };

    });
</script>
</body>

</html>